package org.sixtynine.stock.service.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Criterion;
import org.sixtynine.stock.dao.GenericDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.BaseEntity;
import org.sixtynine.stock.service.GenericService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Thilanka
 * 
 */
@Service
public class GenericServiceImpl implements GenericService {

	@Autowired
	GenericDao genericDao;

	
	@Override
	public void saveList(List<BaseEntity> objs) {
		genericDao.saveList(objs);
	}


	@Override
	public void saveOrUpdate(BaseEntity entity) {
		genericDao.saveOrUpdate(entity);
	}

	@Override
	public void delete(BaseEntity entity) {
		genericDao.delete(entity);
	}

	@Override
	public void delete(int id, Class clazz) {
		genericDao.delete(findById(id, clazz));
	}

	@Override
	public BaseEntity findById(int id, Class clazz) {
		return genericDao.findById(id, clazz);
	}

	@Override
	public List<BaseEntity> findByCriteria(Criterion criterion, Class clazz) {
		return genericDao.findByCriteria(criterion, clazz);
	}

	@Override
	public List<BaseEntity> findByCriteria(Class clazz, Criterion... criterion) {
		return genericDao.findByCriteria(clazz, criterion);
	}

	@Override
	public List<BaseEntity> findAll(Class clazz) {
		return genericDao.findAll(clazz);
	}

	@Override
	public List<BaseEntity> findLatestRecords(int numResuts, Class clazz,
			String orderBy, Criterion... criterion) {
		return genericDao.findLatestRecords(numResuts, clazz, orderBy,
				criterion);
	}

	@Override
	public Page<BaseEntity> findAllWithPaging(Class clazz,
			GridPramDTO gridPramDTO) {
		return genericDao.findAllWithPaging(clazz, gridPramDTO);
	}
}
